<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2018/12/9
  Time: 16:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="${pageContext.request.contextPath}/statics/hplus/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/statics/hplus/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script>

        $(function () {

            $("#dd").on("dbl-click-row.bs.table",function (e,row,ele) {
                $("[name=shangpin_Name]").val(row.shangpin_Name);
                $("[name=shangpinFenlei_Name]").val(row.shangpinFenlei_Name);
                $("[name=shangpin_Id]").val(row.shangpin_Id);
                $("[name=chanpindanwei_Name]").val(row.chanpindanwei_Name);
                $("[name=shangpin_Shoujia]").val(row.shangpin_Shoujia);
                $("#gg").modal('hide')
            })


            $(".zengjia").bootstrapTable({
                url:'${pageContext.request.contextPath}/chanpin/chax1',
                //设置每页多少条数据
                pageSize:4,
                pageList:[2,4,6,8,16],
                height:300,
                pageNumber:1,
                //启用分页，但是默认情况下，是客户端分页的
                pagination:true,
                columns:[
                    {
                        field:'shangpin_Id',
                        title:'编码'
                    },
                    {
                        field:'shangpin_Name',
                        title:'名称'
                    },
                    {
                        field:'shangpinFenlei_Name',
                        title:'分类'
                    },
                    {
                        field:'chanpindanwei_Name',
                        title:'单位'
                    },
                    {
                        field:'shangpin_Shoujia',
                        title:'进价'
                    }
                ]
            }) ;


            //3.绑定操作店铺
            $.post("/dianpu/chax",function (data) {
                var opt = " ";
                $.each(data,function (index,item){
                    var id=item.dianpu_Id;
                    var name=item.dianpu_Name;

                    // alert(id +"---"+ name)
                    opt +="<option value="+id+">"+name+"</option>"
                })
                $("select[name='dianpu_Id']").html(opt);
            })


            //4.绑定经办人
            $.post("/banliren/chax",function (data) {
                var opt = " ";
                $.each(data,function (index,item){
                    var id=item.jinbanr_Id;
                    var name=item.jingbane_Name;

                    // alert(id +"---"+ name)
                    opt +="<option value="+id+">"+name+"</option>"
                })
                $("select[name='jinbanr_Id']").html(opt);
            })

            //4.添加操作人
            $.post("/caozuoleixing/chax1",function (data) {
                var opt = " ";
                $.each(data,function (index,item){
                    var id=item.leixing_Id;
                    var name=item.leixing_Name;

                    // alert(id +"---"+ name)
                    opt +="<option value="+id+">"+name+"</option>"
                })
                $("select[name='leixing_Id']").html(opt);
            })
        })

        function zengjiachangpin() {
            $("#hh").modal('show')
        }

        function zengjiaxiagmu() {
            $("#gg").modal('show')
        }
        var zongjia1;
        function dozengjiaxiangmu() {
            var leixing_Id=$("[name=leixing_Id]").val();
            var dianpu_Id=$("[name=dianpu_Id]").val();
            var jinbanr_Id=$("[name=jinbanr_Id]").val();
            var beizhu=$("[name=beizhu]").val();
            var shangpin_Name=$("[name=shangpin_Name]").val();
            var shangpinFenlei_Name=$("[name=shangpinFenlei_Name]").val();
            var shangpin_Id=$("[name=shangpin_Id]").val();
            var chanpindanwei_Name=$("[name=chanpindanwei_Name]").val();
            var shangpin_Shoujia=$("[name=shangpin_Shoujia]").val();
            var shuliang=$("[name=shuliang]").val();
            $.post("${pageContext.request.contextPath}/ck/chukutianjia",{'caozuoleixing_id':leixing_Id,'dianpu_id':dianpu_Id,'jingbanren':jinbanr_Id,'beizhu':beizhu,'shangpin_Name':shangpin_Name,'shangpinFenlei_Name':shangpinFenlei_Name,'shangpin_Id':shangpin_Id,'chanpindanwei_Name':chanpindanwei_Name,'shangpin_Shoujia':shangpin_Shoujia,'shuliang':shuliang,'danhao':rukudanhao},function (data) {
                zongjia1 = shangpin_Shoujia;
                alert(zongjia1)
                $("#jine").html(zongjia1);
                if (data!=null){
                    alert("添加成功")
                    $("#hh").modal('hide')
                } else {
                    alert("添加失败")
                }
            })
        }

        var rukudanhao;
        $(function () {
            $(function() {
                $.post("${pageContext.request.contextPath}/RuKuTongJi/dhao",function (data) {
                    $("[name=rukudanhao]").val(data);
                    rukudanhao = $("[name=rukudanhao]").val();
                    // alert(rukudanhao)
                })
            })
        })

        function dochangpinchuku() {
            var leixing_Id=$("[name=leixing_Id]").val();
            var dianpu_Id=$("[name=dianpu_Id]").val();
            var jinbanr_Id=$("[name=jinbanr_Id]").val();
            var jine=$("[name=jine]").val();
            var beizhu=$("[name=beizhu]").val();
            var rukudanhao=$("[name=rukudanhao]").val();
            alert(leixing_Id)
            $.post("/RuKuTongJi/chukutianjia",{'caozuoleixing_id':leixing_Id,'dianpu_Id':dianpu_Id,'jingbanren':jinbanr_Id,'jine':jine,'beizhu':beizhu,'rukudanhao':rukudanhao},function (data) {
                if(data!=null){
                    alert("添加成功")
                    alert(data)
                }else {
                    alert("添加失败")
                }
            })
        }

    </script>
</head>
<body>
<div id="div">
    <form method="post"  class="form-horizontal">
        <div class="modal-body" style="height: 70%; width: 80%">
            <div class="ibox-content">
                <h3 style="margin-left: 300px">产品出库</h3>
                <div class="col-sm-10">
                    <label style="margin-left: 40px;margin-top: 20px;font-size: 16px">操作类型：</label>
                    <select name="leixing_Id" style="width: 200px;height: 35px" >

                    </select>

                    <label style="margin-left: 10px;margin-top: 20px;font-size: 16px">操作店铺：</label>
                    <select name="dianpu_Id" style="width: 200px;height: 35px" >

                    </select>
                </div>

                <br>

                <div class="col-sm-10">
                    <label style="margin-left: 40px;margin-top: 20px;font-size: 16px">经办员工：</label>
                    <select name="jinbanr_Id" style="width: 200px;height: 35px" >

                    </select>

                    <label style="margin-left: 30px;margin-top: 20px;font-size: 16px">实付金额：</label>
                    <input id="jine" name="jine" type="text">
                    </select>
                </div>

                <br>

                <div class="col-sm-10">

                    <label style="margin-left: 40px;margin-top: 20px;font-size: 16px">单号：</label>
                    <input name="rukudanhao" >

                    <label style="margin-left: 40px;margin-top: 20px;font-size: 16px">备注：</label>
                    <input name="beizhu">
                </div>

                <br>

                <div class="col-sm-10" style="margin-top: 10px; margin-left: 50px">
                    <a onclick="zengjiachangpin()" style="font-size: 20px">增加产品</a>
                </div>

            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            <button type="button" class="btn btn-primary" onclick="dochangpinchuku()">提交</button>
        </div>
    </form>
</div>

<div class="modal inmodal" id="hh" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" style="width: 60%">
        <div class="modal-content animated bounceInRight" style="height: 90%;">
            <form method="post"  class="form-horizontal">
                <div class="modal-body" style="height: 90%; width: 120%">
                    <div class="ibox-content">
                        <a style="font-size: 20px" onclick="zengjiaxiagmu()">增加项目</a>

                        <h4>项目信息</h4>
                        <div class="col-sm-10">
                            <label style="margin-top: 20px;font-size: 16px">名称：</label>
                            <input  disabled="disabled"  name="shangpin_Name">

                            <label style="margin-top: 20px;font-size: 16px">分类：</label>
                            <input  disabled="disabled"  name="shangpinFenlei_Name">
                        </div>

                        <div class="col-sm-10">
                            <label style="margin-top: 20px;font-size: 16px">编码：</label>
                            <input disabled="disabled"   name="shangpin_Id">

                            <label style="margin-top: 20px;font-size: 16px">单位：</label>
                            <input  disabled="disabled"  name="chanpindanwei_Name">

                            <br>
                            <label style="margin-top: 20px;font-size: 16px">进价：</label>
                            <input id="jianqian" type="text" name="shangpin_Shoujia" disabled="disabled" >
                        </div>

                        <div class="col-sm-10">
                            <h4>续费信息</h4>

                            <div class="col-sm-10">
                                <label  >操作类型：</label>
                                <select name="leixing_Id" style="width: 200px;height: 35px" >

                                </select>

                                <label style="margin-left: 10px;margin-top: 20px;font-size: 16px">操作店铺：</label>
                                <select name="dianpu_Id" style="width: 200px;height: 35px" >

                                </select>
                            </div>

                            <br>

                            <div class="col-sm-10">
                                <label >经办员工：</label>
                                <select name="jinbanr_Id" style="width: 200px;height: 35px" >

                                </select>

                                <label style="font-size: 18px">备注：</label>
                                <input name="beizhu" >
                                </select>
                            </div>

                            <div class="col-sm-10">
                                <label>数量：</label>
                                <input id="shuliang" name="shuliang">

                                <label  style="margin-top: 20px;font-size: 16px">总价：</label>
                                <input id="zongjia" type="text">
                            </div>
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="dozengjiaxiangmu()">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal inmodal" id="gg">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <table id="dd" class="zengjia"></table>
        </div>
    </div>
</div>

<script>
    $("#shuliang").bind("propertychange input",function () {
        var jianqian=$("#jianqian").val();
        var shuliang=$("#shuliang").val();
        $("#zongjia").val(Number(jianqian)*Number(shuliang))
    })
</script>

</body>
</html>
